/**
 * Created by Jacky
 *
 * brief :
 */

define('ssq/view/Table_B', function(require){
    var Base = require('ssq/view/Base');

    var Helper = require('ssq/Helper');

    return KG.Class.define('ssq.view.Table_B', {
        ParentClass : Base,

        eachNumTpl : function(num){
            num = num || '';
            var ss = num ? Helper.Const.HONG[num] : '';
            return '<dd class="cell" data-num="'+num+'">'+ss+'</dd>';
        },

        getTemplate : function(){
            var rs = '',
                arr1 = [1,2,3,4,5],
                arr2 = [6,7,8,9,10,11],
                arr3 = [12,13,14,15,16],
                arr4 = [17,18,19,20,21,22],
                arr5 = [23,24,25,26,27],
                arr6 = [28,29,30,31,32,33];

            rs += [
                '<div class="table-B">',
                '<div class="title">第{{ssq.id}}期</div>',
                '<div class="row row5">'
            ].join('');
            var self = this;
            KG.each(arr1, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row">';
            KG.each(arr2, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row row5">';
            KG.each(arr3, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row">';
            KG.each(arr4, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row row5">';
            KG.each(arr5, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row">';
            KG.each(arr6, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div></div>';

            return rs;
        },

        initView : function(){
            this.callParent('initView');
            var self = this;
            this.ssq.eachHong(function(num){
                self.setHong(num);
            });
        },

        setHong : function(num){
            var jq = this.elem.find('[data-num="'+num+'"]');
            if(jq.length !== 1) return;

            jq.addClass('red');
        }
    });
});
